package com.ruoyi.common.utils;

import com.ruoyi.common.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public final class StringUtil {
    private static final Log log = LogFactory.getLog(StringUtil.class);
    private static final String MOBILE_REG = "^(13[0-9]|147|15[0|1|2|3|5|6|7|8|9]|18[8|9|6|3|7|0|2])\\d{8}$";
    private static final String EMAIL_REG = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
    public static final String EMPTY = null;
	public static final String NULL = "null";
	public static final String BANK = "";
	public static final Long ZERO_LONG = 0L;
	public static final Integer ZERO = 0;
    /**
     * Checkstyle rule: utility classes should not have public constructor
     */
    public StringUtil() {
    }
    //~ Methods ================================================================

    /**
	 * 根据ID设置成8位的字符串.
	 * @param id
	 * @return
	 */
	public static String getId(String id,int length) {
		String buID = "";
		
		int idLength = id.length();
		if(idLength < length){
			for(int i=1; i<=(length- idLength);i++){
				buID = buID +"0";
			}
		}
		return buID+id;
	}
	
	/**
	 * 获取图片文件的后缀名
	 * @param filename
	 * @return
	 */
	public static String getFileType(String filename) {
		if (filename.endsWith(".jpg") || filename.endsWith(".jepg")) {
			return ".jpg";
		} else if (filename.endsWith(".png") || filename.endsWith(".PNG")) {
			return ".png";
		} else {
			return ".jpg";
		}
	}
	
    public static String realplayMobleAndEmail(final String str){
    	try {
    		String s = str;
        	//手机
        	Pattern p=Pattern.compile(MOBILE_REG);
        	//邮件
        	Pattern p2=Pattern.compile(EMAIL_REG); 
        	Matcher m2=p2.matcher(str); 
        	Matcher m=p.matcher(str); 
        	if(s.length()==11&&m.find()){
        		String st = s.substring(0,3);
        		String stEnd = s.substring(7,s.length());
        		s = st +"****"+stEnd;
        	}else if (m2.find()) {
        		int i = s.indexOf("@");
        		String st = s.substring(0,i+1);
        		s = st + "****";
    		}
        	return s;
		} catch (Exception e) {
			log.info("匹配手机号码，邮箱号码变为*号error");
			return str;
		}
    }
  
    /**
     * 替换硬回车
     * @param content
     * @return
     */
    public static String replaceBR(String content){
    	return content.replaceAll("\r\n", "<br/>");
    }
	/**
	 * 判断传入的字符串是否为空串,如果是null的就替换为""空字符串.
	 * 
	 * @return
	 */
	public static String replaceNullStr(String str) {
		if(str==null){
			return "";
		}
		if(!isEmptyString(str)){
			if("null".equals(str)){
				str=str.replace("null", "");
				return str;
			}else{
				return str;	
			}
		}else{
			return str;
		}
	}
    /**
     * 替换特殊字符
     */
    public static String realplaySpecialCharacters(String content){
    	String[] strChar = new String[]{"+", "-", "$", "&", "|", "||", "!", "(", ")", "{", "}", "[", "]", "^", "/", "~", "*", "?", ":", "\"", "'",">","<"};
    	for (int i = 0; i < strChar.length; i++) {
			String string = strChar[i];
			content = content.replace(string, "");
		}
    	return content;
    }
    
    /**
	 * 
	 * 功能 :判断字符串是否 为"null","NULL","0","0L","Map.isEmpty","List.isEmpty"
	 * 
	 * @param object
	 *            待判断的字符串
	 * @return true 为"null","NULL","0","0L","Map.isEmpty","List.isEmpty",false 反之.
	 */
	public static boolean isEmpty(Object object){
		if(object == null){
			return true;
		}
		if(object instanceof String){
			String tempStr = object.toString();
			if(StringUtils.isEmpty(tempStr) || StringUtils.isBlank(tempStr)){
				return true;
			}
			if("null".equalsIgnoreCase(tempStr)){
				return true;
			}
			if("undefined".equalsIgnoreCase(tempStr)){
				return true;
			}
		}
		if(object instanceof Integer){
			Integer i = (Integer)object;
			return StringUtil.ZERO.equals(i);
		}
		if(object instanceof Long){
			Long l = (Long)object;
			return StringUtil.ZERO_LONG.equals(l);
		}
		if(object instanceof Map<?, ?>){
			Map<?, ?> map = (Map<?, ?>)object;
			if(map.isEmpty()){
				return true;
			}
		}
		if(object instanceof List<?>){
			List<?> list = (List<?>)object;
			if(list.isEmpty()){
				return true;
			}
		}
		if(object instanceof Integer[]){
			Integer[] array = (Integer[])object;
			if(ZERO == array.length){
				return true;
			}
		}
		if(object instanceof String[]){
			String[] array = (String[])object;
			if(ZERO == array.length){
				return true;
			}
		}
		return false;
	}
	
	/**
	 * 
	 * @param object
	 * @return
	 */
	public static boolean isNotEmpty(Object object){
		return !isEmpty(object);
	}
    
    /**
     * Splits a String on a delimiter into a List of Strings.
     * @param str the String to split
     * @param delim the delimiter character(s) to join on (null will split on whitespace)
     * @return a list of Strings
     */
    public static List split(String str, String delim) {
        List splitList = null;
        StringTokenizer st = null;

        if (str == null)
            return splitList;

        if (delim != null)
            st = new StringTokenizer(str, delim);
        else
            st = new StringTokenizer(str);

        if (st != null && st.hasMoreTokens()) {
            splitList = new ArrayList();

            while (st.hasMoreTokens())
                splitList.add(st.nextToken());
        }
        return splitList;
    }
    
    public static boolean included(String ids,String id){
    	StringTokenizer tokens = new StringTokenizer(ids,",");
    	while(tokens.hasMoreTokens()){
    		if (tokens.nextToken().equals("'"+id.trim()+"'")){
    			return true;
    		}
    	}
    	return false;
    }
    
    public static boolean included(String ids,String[] id){
    	for (int i=0;i<id.length;i++){
    		StringTokenizer tokens = new StringTokenizer(ids,",");
	    	while(tokens.hasMoreTokens()){
	    		if (tokens.nextToken().equals("'"+id[i].trim()+"'")){
	    			return true;
	    		}
	    	}
    	}
    	return false;
    }
    /**
     * 根据传入的len长度截断source字符串
     * @param len
     * @param source
     * @return
     */
    public static String cutString(int len,String source){
    	
    	if(source!=null&&source.length()>=len){
    		/*String returnStr = "";
    		String clone = source;
    		while(clone.lastIndexOf("<")>-1&&clone.lastIndexOf("<")>-1){
    			returnStr = clone.substring(beginIndex, endIndex)
    		}*/
    		
    		return source.substring(0, len)+"…";
    	}else{
    		return source;
    	}
    }
    
    public static String cutString2(int len,String source){
    	if(source.length()>=len){
    		return source.substring(0, len)+"… ";
    	}else{
    		return source;
    	}
    }
    
    /**
     * 屏蔽手机的方法
     * @param source 手机号
     * @return
     */
    public static String hiddenMobile(String source) {
    	if (null == source) {
    		return "";
    	}
    	Pattern pattern = Pattern.compile("^1\\d{10}$");

		if (pattern.matcher(source).matches()) {
			return source.substring(0,4) + "****" + source.substring(8);
		} else {
			return source;
		}
    }
   
    /**
     * 屏蔽字符串方式
     * @param source 字符串
     * @param number 显示位数
     * @param viewNumber 加*位数
     * @return
     */
    public static String hiddenStr(String source,int number,int viewNumber) {
    	if ( null == source || "" == source) {
    		return "******";
    	}
    	
    	String xing = "";
    	if(viewNumber>0){
    		for(int i=0;i<viewNumber;i++){
    			xing = xing + "*";
    		}
    	}
		if (source.length()>number) {
			return source.substring(0,number) + xing;
		} else {
			return source;
		}
    }
    
   
    /**
     * 生成随机字符串
     * @param random
     * @param len
     * @return
     */
	public static String getRandomString( int random, int len ){
	    java.util.Random rd = new java.util.Random();
	    StringBuffer sb = new StringBuffer();
	    int rdGet; // 取得随机数 
	    char ch;
	     
	    for ( int i = 0 ; i < len; i ++ ){
	        rdGet = Math.abs(rd.nextInt()) % 10 + 48 ; // 产生48到57的随机数(0-9的键位值)   
	        //rdGet=Math.abs(rd.nextInt())%26+97; // 产生97到122的随机数(a-z的键位值) 
	        ch = ( char ) rdGet;
	        sb.append( ch );
	    } 	     
	    return sb.toString();
	} 
	/**
	 * 将传入的float保留2位小数
	 * @return
	 */
	public static String formatFloatFor2Pos(Float f){
		DecimalFormat myformat=new DecimalFormat("#0.00");
		return myformat.format(f);
	}
	/**
	 * 替换null对象或者null字符
	 * @param object
	 * @return
	 * @author dengcheng
	 */
	public static String trimNullValue(String object){
		if(object == null ||"null".equals(object)){
			return "";
		}
		return object;
	}
	public static String formatFloatFor2Pos(Float f1,Float f2){
		float ff = f1 - f2;
		DecimalFormat myformat=new DecimalFormat("#0.0");
		return myformat.format(ff);
	}

	public static String formatFloatFor0Pos(Float f){
		DecimalFormat myformat=new DecimalFormat("#0");
		return myformat.format(f);
	}
	/**
	 * 过滤html文档
	 * @param inputString
	 * @return
	 */
	public static String filterOutHTMLTags(String inputString) {
		String htmlStr = inputString; // 含html标签的字符串
		String textStr = "";
		Pattern p_script;
		Matcher m_script;
		Pattern p_style;
		Matcher m_style;
		Pattern p_html;
		Matcher m_html;

		try {
			String regEx_script = "<[\\s]*?script[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?script[\\s]*?>"; // 定义script的正则表达式{或<script[^>]*?>[\\s\\S]*?<\\/script>																						// }
			String regEx_style = "<[\\s]*?style[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?style[\\s]*?>"; // 定义style的正则表达式{或<style[^>]*?>[\\s\\S]*?<\\/style>
			String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式

			p_script = Pattern.compile(regEx_script, Pattern.CASE_INSENSITIVE);
			m_script = p_script.matcher(htmlStr);
			htmlStr = m_script.replaceAll(""); // 过滤script标签

			p_style = Pattern.compile(regEx_style, Pattern.CASE_INSENSITIVE);
			m_style = p_style.matcher(htmlStr);
			htmlStr = m_style.replaceAll(""); // 过滤style标签

			p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
			m_html = p_html.matcher(htmlStr);
			htmlStr = m_html.replaceAll(""); // 过滤html标签

			textStr = htmlStr;
		} catch (Exception e) {
			System.err.println("Html2Text: " + e.getMessage());
		}
		return textStr;// 返回文本字符串
	}
	
	
	/**
	 * 判断传入的字符串是否为空串
	 * @return
	 */
	public static boolean isEmptyString(String str){
		return str==null ? true : str.trim().equals("") ? true : false;
	}
	/**
	 * 根据传入的len值分割str成为一个map，map里的每个元素长度都等于len
	 * @param str
	 * @param len
	 * @return
	 */
	public static Map splitStrByLen(String str,int len){
		Map strMap = new HashMap();
		int cnt = 0;
		if(str!=null){
			if(str.length()>len){
				while(str.length()>len){
					strMap.put(cnt, str.substring(0, len));
					str = str.substring(len,str.length());
					cnt++;
				}
				strMap.put(cnt, str);
			}
			strMap.put(cnt, str);
				
			return strMap;
		}else{
			return null;			
		}
		
	}

	/**
	 * 字符串 分割 LIST　集合. 
	 * @param str 需要分割的字符串
	 * @param len 以什么为分割
	 * @return
	 */
	public static List<String> getListByString(String str,String len){
		if(StringUtil.isNotEmpty(str)){
			str = StringUtil.filterChar(str, len);
		}
		List<String> list = new ArrayList<String>();
		String sonids = str.replace(" ","");
		String[] ids = sonids.split(len);
		if(ids!=null && ids.length>0){
			for(int i=0;i<ids.length;i++){
				list.add(ids[i]);
			}
		}
		return list;
	}
	
	/**
	 * 验证是否是有效的手机号
	 * 
	 * @param mobile 手机号
	 * @return
	 */
	public final static boolean validMobileNumber(final String mobile) {
		if (StringUtils.isEmpty(mobile)) {
			return false;
		}

		Pattern pattern = Pattern.compile(MOBILE_REG);

		if (!pattern.matcher(mobile).matches()) {
			log.info(mobile + "不是有效的手机号码.");
			return false;
		}
		return true;
	}
	
	
	public final static boolean validateUserName(String code){
		Pattern pattern = Pattern.compile("^[A-Za-z0-9]{4,16}+$");
		if (!pattern.matcher(code).matches()) {
			log.info(code + "用户名必须由6-16位数字和字母组成");
			return false;
		}
		return true;
	}
	
	public final static boolean validNickname(final String nickName) {
		/**
		 * @ TODO 配置敏感词
		 */
		return true;
	}
	
	
	/**
	 * 校验是否是有效的邮件地址
	 * 
	 * @param email 邮箱地址
	 * @return
	 */
	public final static boolean validEmail(final String email) {
		if (StringUtils.isEmpty(email)) {
			return false;
		}
		Pattern pattern = Pattern.compile(EMAIL_REG);
		if (!pattern.matcher(email).matches()) {
			log.info(email + "不是有效的邮箱地址.");
			return false;
		}
		return true;
	}
	
	public final static boolean validMembershipCard(final String membershipCard) {
		return true;
	}
	
	public final static String replaceQuoteInJS(final String str) {
		if (null == str) {
			return "";
		} else {
			return str.replaceAll("\\\"", "\\\\\"");
		}
	}
	/**
	 * 替换模板中的变量。变量的标识符为${}。
	 * 例如，模板中${name}变量将会被Map列表中键名为name的键值替换，如果Map列表中不存在所需要
	 * 的键名，则会被替换成空。
	 * @param template 模板
	 * @param data  参数列表
	 * @return 有效的模板内容
	 * @throws Exception Exception
	 */
	public static String composeMessage(final String template, final Map<String, Object> data) throws Exception {
		String regex = "\\$\\{(.+?)\\}";
		Pattern pattern = Pattern.compile(regex);
		Matcher matcher = pattern.matcher(template);

		/*
		 * sb用来存储替换过的内容，它会把多次处理过的字符串按源字符串序
		 * 存储起来
		 */
		StringBuffer sb = new StringBuffer();
		while (matcher.find()) {
			String name = matcher.group(1); //键名
			String value = null == data.get(name) ? "" : data.get(name).toString(); //键值
			if (value == null) {
				value = "";
			} else {
				value = value.replaceAll("\\$", "\\\\\\$");
			}

			matcher.appendReplacement(sb, value);
		}

		matcher.appendTail(sb);
		return sb.toString();
	}
	
	/**
	 * 替换或截短用户名
	 * 若用户名是手机号、邮箱或用户名为lv+手机号，则部分字符用*替换，其它根据传入的长度截短
	 * @param len (-1表示不截短)
	 * @param userName
	 * @return
	 */
	public static String replaceOrCutUserName(int len, String userName) {
		Pattern userNamePt = Pattern.compile("^lv[0-9]{11}$");		
        String str = realplayMobleAndEmail(userName);		
        
		if (!str.equals(userName)) {
			return str;
		} else if (userNamePt.matcher(userName).find() && validMobileNumber(userName.substring(2, userName.length()))) {
			return userName.substring(0, userName.length()-4) + "****";
		}
		
		return len == -1 ? str : cutString2(len, str);
	}
	
	
	/**
	 * 导出文件时文件名的生成.
	 * @param name
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	public static String xlsName(String name ,String startTime ,String endTime){
		String linkName = name;
		if(StringUtils.isNotEmpty(startTime)){
			linkName = linkName + "("+startTime.replaceAll("-","").substring(0, 8)+"-";
		}else{
			linkName = linkName + "("+ DateUtil.format(DateUtil.getDayStart(new Date()), DateUtil.YMDHMS_A).replaceAll("-","").substring(0, 8)+"-";
		}
		if(StringUtils.isNotEmpty(endTime)){
			linkName = linkName + "-"+endTime.replaceAll("-","").substring(0, 8)+")";
		}else{
			linkName = linkName + "-"+DateUtil.format(DateUtil.getDayEnd(new Date()), DateUtil.YMDHMS_A).replaceAll("-","").substring(0, 8)+")";
		}
		try {
			linkName = new String(URLDecoder.decode(linkName,"UTF-8").getBytes(), "ISO8859-1");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return linkName;
	}
	
	/**
	 * 导出文件时文件名的生成.
	 * @param name
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	public static String xlsName(String name){
		String linkName = name;
		try {
			linkName = new String(URLDecoder.decode(linkName,"UTF-8").getBytes(), "ISO8859-1");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return linkName;
	}
	
	/**
	 * 过滤为空的字符串.
	 * @param ids
	 * @param spilt
	 * @return
	 */
	public static String formatStr(String ids,String spilt){
		String names = "";
		String[] prodIds = ids.split(",");
		if(ids!=null && prodIds.length>0){
			for(int i=0;i<prodIds.length;i++){
				String id = prodIds[i];
				if(StringUtil.isNotEmpty(id)){
					names = names + id + ",";
				}
			} 
		}
		return names.substring(0, names.length()-1);
	}
	
	/**
	 * 去除前后空格后的字符串.
	 * @param ids
	 * @return
	 */
	public static String formatStrTrim(String ids){
		if(StringUtil.isNotEmpty(ids)){
			return ids.trim();
		}else{
			return "";
		}
	}
	
	
	/**
	 * 获取当前操作系统
	 * @return
	 */
	public static String sysName() {
		Properties props = System.getProperties();
		String name = props.getProperty("os.name").toLowerCase();
		if (name.contains("windows")) {
			return "windows";
		} else if (name.contains("linux")) {
			return "linux";
		} else if (name.contains("unix")) {
			return "unix";
		} else {
			return name;
		}
	}
	
	/**
	 * 
	 * @return
	 */
	public static boolean isTest(){
		String sysName = sysName();
		if("windows".equalsIgnoreCase(sysName)){
			return true;
		}else{
			return false;
		}
	}
	
	/**
	 * 数字相除取百分比.两位小数.
	 * @param a 分子
	 * @param b 分母
	 * @param digits 位数
	 * @return
	 */
	public static String digitSize(Long a,Long b,Long digits) {
		DecimalFormat df = new DecimalFormat("0.00");
		if(digits == 1L){
			df = new DecimalFormat("0.0");//格式化小数    
		}
		if(a==0 || b==0 ){
			if(digits == 1L){
				return "0.0";
			}else{
				return "0.00";
			}
		}else{
			return df.format((float)a/b*100);
		}
	}
	
	/**
	 * 相除有小数，则整数加一.
	 * @param a
	 * @param b
	 * @return
	 */
	public static int digitSize(int a,int b) {
		int c = 0;
		if(a%b!=0){
			c = a/b+1;
		}else{
			c = a/b;
		}
		return c;
	}
	/**
	 * 去掉字符串的首尾特殊符号.
	 * @param str
	 * @param chars
	 * @return
	 */
	public static String filterChar(String str,String chars){
		if(StringUtil.isNotEmpty(str)){
			str = filterInChar(str," ");
			if(chars.equalsIgnoreCase(str.substring(0, 1))){
				str = str.substring(1, str.length());
			}
			if(chars.equalsIgnoreCase(str.substring(0, 1))){
				str = str.substring(1, str.length());
			}
			if(chars.equalsIgnoreCase(str.substring(str.length()-1, str.length()))){
				str = str.substring(0,str.length()-1);
			}
			if(chars.equalsIgnoreCase(str.substring(str.length()-1, str.length()))){
				str = str.substring(0,str.length()-1);
			}
		}
		return str;
	}
	
	/**
	 * 去掉字符串中所有的特殊符号.
	 * @param str
	 * @param chars
	 * @return
	 */
	public static String filterInChar(String str,String chars){
		return str.replace(chars,"");
	}
	
	/**
	 * 分母，分子 
	 * @param a 分子
	 * @param b 分母
	 * @return
	 */
	public static String toRatio(Long a, Long b) {
		if (a == 0L || b == 0L) {
			return "0.00";
		} else {
			float num = (float) (a * 100) / b;
			DecimalFormat df = new DecimalFormat("0.00");// 格式化小数
			String s = df.format(num);
			return s;
		}
	}
	
	/**
	 * 反向过滤(父去掉子之后的数据).
	 * @param father
	 * @param son
	 * @param chars
	 * @return
	 */
	public static String directFilter(String father,String son,String chars){
		if(isNotEmpty(father) && isNotEmpty(son)){
			//1.先过滤字符串
			father = filterChar(father,chars);
			son = filterChar(son,chars);
			//2.判断父是否包含子
			boolean flag = isExitSub(father,son,chars);
			if(flag){
				int size = father.indexOf(son);
				father = father.substring(0,size) + father.substring(size + son.length()+chars.length(),father.length());
			}
		}
		return father;
	}
	
	
	/**
	 * 判断子是否在父之中.
	 * @param father
	 * @param son
	 * @param chars
	 * @return
	 */
	public static boolean isExitSub(String father,String son,String chars){
		boolean flag = false;
		if(StringUtil.isNotEmpty(father)){
			flag = true;
		}
		if(StringUtil.isNotEmpty(son)){
			flag = true;
		}
		if(flag && StringUtil.isNotEmpty(chars)){
			flag = false;
			String[] fIds = father.split(chars);
			if(fIds!=null && fIds.length>0){
				for(int i=0;i<fIds.length;i++){
					String fid = fIds[i];
					if(fid.equalsIgnoreCase(son)){
						flag = true;
					}
				}
			}
		}
		
		if(flag && StringUtil.isEmpty(chars)){
			flag = false;
			int a = father.indexOf(son);
			if(a>=0){
				flag = true;
			}
		}
		return flag;
	}
	
	/**
	 * 为字符串添加''.如果SUCCESS,FAIL改变为'SUCCESS','FAIL'
	 * @param ids
	 * @param chars
	 * @return
	 */
	public static String fiterStrIdsByIds(String ids,String chars){
		String strIds = "";
		if(StringUtil.isNotEmpty(ids) && StringUtil.isNotEmpty(chars)){
			String[] fIds = ids.split(chars);
			if(fIds!=null && fIds.length>0){
				for(int i=0;i<fIds.length;i++){
					String fid = fIds[i];
					strIds = strIds +",'" + fid+"'";
				}
			}
		}
		if(StringUtil.isNotEmpty(strIds)){
			strIds = filterChar(strIds,",");
		}
		return strIds;
	}
	
	
	/**
	 * 过滤字符串中相同的值.
	 * @param charStr
	 * @param chars
	 * @return
	 */
	public static String[] arrayUnique(String charStr,String chars) {
		String[] uniqueStr = charStr.split(chars);
		Set<String> set = new HashSet<String>();  
		set.addAll(Arrays.asList(uniqueStr));  
		return set.toArray(new String[0]);  
	}  
	
	/**
	 * 过滤后台菜单URL
	 * @param actionUrl
	 * @return
	 */
	public static String buildUrl(String actionUrl){
		if(StringUtil.isNotEmpty(actionUrl)){
			if(StringUtil.isNotEmpty(actionUrl)){
				String startChar = actionUrl.substring(0,actionUrl.indexOf("?")+1);
				String endChar = filterInChar(actionUrl.substring(actionUrl.indexOf("?")+1, actionUrl.length())," ");
				String filterEndChar = "";
				if(StringUtil.isNotEmpty(endChar)){
					String[] endSonUnique = arrayUnique(endChar,"&");
					String filterEnd = "";
					for(int t=0;t<endSonUnique.length;t++){
						String sonModuleChar = endSonUnique[t];
						String startSon = sonModuleChar.substring(0,sonModuleChar.indexOf("=")+1);
						String endSon = filterInChar(sonModuleChar.substring(sonModuleChar.indexOf("=")+1, sonModuleChar.length())," ");
						
						if(StringUtil.isNotEmpty(endSon)){
							String[] sonUnique = endSon.split(",");
							String sonChar = "";
							boolean falg = true;
							for(int tt=0;tt<sonUnique.length;tt++){
								if(StringUtil.isNotEmpty(sonUnique[tt]) && falg){
									sonChar =  sonChar + sonUnique[tt] + ",";
								}else{
									falg = false;
								}
							}
							if(falg){
								filterEnd = filterEnd +"&"+ startSon +  filterChar(sonChar,",");
							}
						}
					}
					
					filterEndChar = filterChar(filterEnd,"&");
				}
				actionUrl = startChar + filterEndChar;
			}
			actionUrl = filterChar(actionUrl,"&");
		}
		return actionUrl;
	}
	
 
	public static void main(String[] args) {
//		System.out.println(digitSize(0L,0L,1L));
//		System.out.println(digitSize(1L,1L,1L));
		
//		String sonids = "isOffHourExec,abcdef,callQueue,987000,fanyun_987,t,abcdef";
//		List<String> handleSonids = new ArrayList<String>();
//		String[] ids = sonids.split(",");
//		if(ids!=null && ids.length>0){
//			for(int i=0;i<ids.length;i++){
//				String fid = ids[i];
//				if(i>1){
//					handleSonids.add(fid);
//				}
//			}
//		}
////		System.out.println(handleSonids.size());
//		String aa = "[\"http://tmp/dSRR06fKxNUxb25924178fe2d5eac1794dc7119a2a9b.jpg\"]";
//		String bb = "http://tmp/dSRR06fKxNUxb25924178fe2d5eac1794dc7119a2a9b.jpg\"]";
//		int begin = bb.indexOf("http");
//		int end = bb.indexOf(".jpg");
//		System.out.println(bb.substring(begin, end));
		
//		String words = "20210922235746002.jpg";
//		words = words.replaceAll("20210922235746002.jpg","asd.jpg ");
//		System.out.println(words);    // 输出：你好 java,你好 php
		
		System.out.println(digitSize(8,4));
		System.out.println(digitSize(8,3));
		
	}


}
